package thread;

public class DaemonThreadDemo {
    public static void main(String[] args) {
        System.out.println("一天，宋文杰与王文鑫一起去玩耍");
        System.out.println("突然到来悬崖边");
        Thread rose=new Thread(){
            public void run(){
                for (int i = 0; i < 3; i++) {
                    try {
                        Thread.sleep(2000);
                        System.out.println("王文鑫:哦宋文杰，我跳崖了");
                    } catch (InterruptedException e) {
                    }
                }
                System.out.println("噗通,宋文杰看着王文鑫跳下了悬崖");
            }
        };

        Thread jack=new Thread(){
            public void run(){
                while (true){
                    try {
                        Thread.sleep(2500);
                        System.out.println("宋文杰: 哦王文鑫，你不要跳，你跳我会跟着的");
                    } catch (InterruptedException e) {

                    }
                }
            }
        };
        rose.start();
        jack.setDaemon(true);
        jack.start();


    }
}
